package sealedGenerator;

import java.util.ArrayList;
import sealedGenerator.card.Color;
import sealedGenerator.card.Rarity;

public class Card {
	private final String manaCost;
	private final Integer convertedManaCost;
	private final ArrayList<Color> color;
	private final String name;
	private final String superType;
	private final String type;
	private final String subType;
	private final String rulesText;
	private final Integer power;
	private final Integer toughness;
	private final Rarity rarity;
	private final Set set;
	
	//encapsulates all information about a M:TG card
	public Card(String manaCost, Integer cmc, ArrayList<Color> color, String name,
			String superType, String type, String subType, String rulesText,
			Integer power, Integer toughness, Rarity rarity, Set set){
		this.manaCost=manaCost;
		this.convertedManaCost=cmc;
		this.color=color;
		this.name=name;
		this.superType=superType;
		this.type=type;
		this.subType=subType;
		this.rulesText=rulesText;
		this.power=power;
		this.toughness=toughness;
		this.rarity=rarity;
		this.set=set;
	}
	public String getManaCost(){
		return manaCost;
	}
	public Integer getCMC(){
		return convertedManaCost;
	}
	public ArrayList<Color> getColors() {
		return color;
	}
	public String getName() {
		return name;
	}
	public String getSuperType() {
		return superType;
	}
	public String getType() {
		return type;
	}
	public String getSubType() {
		return subType;
	}
	public String getRulesText() {
		return rulesText;
	}
	public Integer getPower() {
		return power;
	}
	public Integer getToughness() {
		return toughness;
	}
	public Rarity getRarity() {
		return rarity;
	}
	public Set getSet() {
		return set;
	}
	public boolean isColor(Color wantedColor) {
		return color.contains(wantedColor);
	}
	
	public String getMWSDeckString(int count) {
		return "    " + count + " [" + getSet().getExpansionCode() + "] " + getName() + "\r\n";
	}
	
	@Override
	public String toString(){
		StringBuilder returnString=new StringBuilder();
		returnString.append(name);
		returnString.append(" ");
		
		if(manaCost==null){
			returnString.append("(none)");
		} else{
			returnString.append("(");
			returnString.append(manaCost);
			
			if(color != null && color.size() > 0) {
				returnString.append(" - ");
				
				for(Color c: color) {
					if(c != color.get(0))
						returnString.append(", ");
					
					returnString.append(c);
				}
			}
			
			returnString.append(")");
		}
		
		returnString.append(" ");
		if(superType !=null){
			returnString.append(superType);
			returnString.append(" ");
		}
		returnString.append(type);
		if(subType != null){
			returnString.append("-");
			returnString.append(subType);
		}
		returnString.append(" ");
		if(rulesText !=null){
			returnString.append(rulesText);
			returnString.append(" ");
		}
		if(power !=null){
			returnString.append(power);
			returnString.append("/");
			returnString.append(toughness);
			returnString.append(" ");
		}
		returnString.append(rarity);
		// returnString.append(" ");
		// returnString.append(set);
		return returnString.toString();
	}
}